<?php
class Index_con extends Wx{

    public $projectId = '1481169291265';
    //public $ucenterurl = 'http://usertest.zhongsou.com:8001/usercenter';
    //public $scenterurl = 'http://supertest.zhongsou.com:8001/super';
	
	//首页
	public function index(){
		$hid=intval($_GET["hid"]); 
		if(empty($hid)){die("酒店信息错误");}
		$view = $this->viewdata("*","hotel","where id={$hid}");
		$temppic[0]='http://test.s.zhongsou.com/minisite/hotel/img/bg_hotel_2.jpg';
		$temppic[1]='http://test.s.zhongsou.com/minisite/hotel/img/bg_hotel_3.jpg';
		$temppic[2]='http://test.s.zhongsou.com/minisite/hotel/img/bg_hotel.jpg';
		$picarr=unserialize($view["pic"]);
		if(!empty($picarr)){
			for($i=0;$i<3;$i++){
				if(empty($picarr[$i])){
					$picarr[$i]=$temppic[$i];
				}else{
					continue;
				}
			}
		}else{
			$picarr = $temppic;
		}
		$view["pic"]=$picarr;
		$this->smarty->assign("view",$view);
		$this->smarty->assign("hid",$hid);
		$this->smarty->display("hotel.tpl");
	}
	
	//酒店文章
	public function hshow(){
		$hid=intval($_GET["hid"]);
		if(empty($hid)){die("酒店信息错误");}
		$type=intval($_GET["type"]);
		if(empty($type)){die("文章类型错误");}
		$view = $this->viewdata("*","hotel","where id={$hid}");
		$content = $view["intro".$type];
		$tarr=array(1=>"酒店介绍",2=>"餐饮预订",3=>"特价优惠");
		$this->smarty->assign("title",$tarr[$type]);
		$this->smarty->assign("content",$content);
		$this->smarty->display("hshow.tpl");
	}
	
	
	//酒店预订
	public function booking(){
		$hid=intval($_GET["hid"]);
		if(empty($hid)){die("酒店信息错误");}
		$uinfo = $_SESSION["uinfo"];
		if(empty($uinfo)){
			header("location:?a=login&hid={$hid}");
			exit;
		}
		$order=$_GET["order"];
		$tids=trim($_GET["tids"],",");
		$isfood=$_GET["isfood"];
		$view = $this->viewdata("*","hotel","where id={$hid}");
		$where="where hid={$hid}";
		if(!empty($tids)){
			$where.=" and id IN({$tids})";
		}
		$list = $this->arrdata("*","hotel_type",$where,"id desc");
		foreach($list as $k=>$v){
			$where="where hid={$hid} and tid={$list[$k]['id']} and status=1";
			if(!empty($isfood)){$where.=" and is_breakfast={$isfood}";}
			$project = $this->arrdata("*","hotel_type_project",$where);
			$lowprice=0;
			foreach($project as $kk=>$vv){
				if($project[$kk]["is_breakfast"]==1){
					$project[$kk]["isfood"]='含早餐';
				}else{
					$project[$kk]["isfood"]='不含早餐';
				}
				$project[$kk]["num"] = $this->numdata("hotel_room","where status=1 and rtype=1 and hid={$hid} and tid={$list[$k]['id']} and pid={$project[$kk]['id']}");
				if(empty($lowprice)){
					$lowprice = $project[$kk]["pacific_price"];
				}else{
					if($lowprice>$project[$kk]["pacific_price"]){
						$lowprice=$project[$kk]["pacific_price"];
					}
				}
				
			}
			$list[$k]["project"]=$project;
			$list[$k]["lowprice"]=$lowprice;
		}
		if($order=='price'){
			$list = arrsort($list,"lowprice","asc");
		}
		$alllist = $this->arrdata("id,name","hotel_type","where hid={$hid}");
		$this->smarty->assign("alllist",$alllist);
		$this->smarty->assign("list",$list);
		$this->smarty->assign("view",$view);
		$this->smarty->assign("hid",$hid);
		$this->smarty->display("orderRoom.tpl");
	}
	
	//订单确认
	public function order(){
		$uinfo = $_SESSION["uinfo"];
		$hid=intval($_GET["hid"]);
		if(empty($hid)){die("酒店信息错误");}
		if(empty($uinfo)){
			header("location:?a=login&hid={$hid}");
			exit;
		}
		$rid=intval($_GET["rid"]);
		if(empty($rid)){die("房型信息错误");}
		$pid=intval($_GET["fid"]);
		if(empty($pid)){die("方案信息错误");}
		//查询选择的方案信息
		$finfo = $this->viewdata("*","hotel_type_project","where id={$pid}");
		$isfood = $finfo["is_breakfast"]==1?'含早餐':'不含早餐';
		//查询房型信息
		$tinfo = $this->viewdata("*","hotel_type","where id={$finfo['tid']}");
		$btim=$_GET["btim"];
		$etim=$_GET["etim"];
		if(empty($btim) || empty($etim)){die("住店时间错误");}
		//算出各种类型各几天
		$dayinfo = $this->getstim($btim,$etim);
		$price = intval($dayinfo["s"]) * $finfo["special_price"] + intval($dayinfo["w"]) * $finfo["weekend_price"] + intval($dayinfo["n"]) * $finfo["pacific_price"];
		//算出同种现在可用房总数
		$selnum = $this->numdata("hotel_room","where tid={$finfo['tid']} and pid={$finfo['id']} and status=1 and rtype=1");
		if($selnum<1){
			$select='<select id="select" name="rnum" onChange="getTotal()" disabled="disabled"><option value="0">暂无房间可用</option>';
		}else{
			$select='<select id="select" name="rnum" onChange="getTotal()">';
			for($i=1;$i<=$selnum;$i++){
				$select.='<option value="'.$i.'">'.$i.'</option>';
			}
		}
		$select.="</select>";
		$this->smarty->assign("allday",$dayinfo["all"]);
		$this->smarty->assign("dayinfo",$dayinfo);
		$this->smarty->assign("price",$price);
		$this->smarty->assign("btim",$btim);
		$this->smarty->assign("etim",$etim);
		$this->smarty->assign("finfo",$finfo);
		$this->smarty->assign("isfood",$isfood);
		$this->smarty->assign("tinfo",$tinfo);
		$this->smarty->assign("select",$select);
		$this->smarty->display("hotel_order_flii.tpl");
	}
	
	//换算周末与特殊日
	public function getstim($btim,$etim){
		$daytime=$btim=strtotime($btim);
		$etim=strtotime($etim);
		$snum=0;
		$wnum=0;
		$nnum=0;
		while($daytime<$etim){
			$day=date("Y-m-d",$daytime);
			$v = $this->viewdata("id","hotel_times","where find_in_set('{$day}',times)");
			if(!empty($v)){
				$snum++;
			}elseif(date("N",$daytime)==5 || date("N",$daytime)==6){
				$wnum++;
			}else{
				$nnum++;
			}
			$daytime+=86400;
		}
		$dayinfo["s"]=$snum;
		$dayinfo["w"]=$wnum;
		$dayinfo["n"]=$nnum;
		$dayinfo["all"]=$snum+$wnum+$nnum;
		return $dayinfo;
	}
	
	
	//微信支付页
	public function wxpay(){
		$sn=$_GET["sn"];
		if(empty($sn)){die("{$sn}订单信息错误");}
		$uinfo=$_SESSION["uinfo"];
		//订单信息
		$orderinfo=$this->viewdata("id,uid,hid,order_sn,amount,in_time,out_time,info","hotel_order","where order_sn='{$sn}'");
		if(empty($uinfo)){
			header("location:?a=login&hid={$orderinfo['hid']}");
			exit;
		}
		if(empty($orderinfo)){die("订单信息错误");}
		//酒店信息
		$hotelinfo=$this->viewdata("*","hotel","where id={$orderinfo['hid']}");
		$userid=$hotelinfo["uid"];
		//住房信息
		$info = unserialize($orderinfo["info"]);
		$tname = $this->oncedata("name","hotel_type","where id={$info[0]['tid']}");
		$pname = $this->oncedata("name","hotel_type_project","where id={$info[0]['pid']}");
		//微信信息
		$wxguest = $this->viewdata("*","wxguest","where userid={$userid} and uid='".$uinfo['uid']."'");
		
		//统一支付接口
		$data["userid"]=$userid;
		$data["sn"]=$sn;
		$data["title"] = $tname." ".$pname;
		$data["body"]=$tname;
		$data["price"]=$orderinfo["amount"];
		$data["url"]=$this->basehost."minisite/hotel/?a=notify&orderid={$orderinfo['id']}";
		$data["ip"]=getuserip();
		//if(!empty($wxguest["openid"])){$data["openid"]=$wxguest["openid"];}
		$paydata=base64_encode(json_encode($data));
		header("location:{$this->basehost}api/wxpay.php?wxpaydata={$paydata}");
		exit;
	}
	
	//支付宝支付页
	public function alipay(){
	    $sn=$_GET["sn"];
	    if(empty($sn)){die("{$sn}订单信息错误");}
	    $uinfo=$_SESSION["uinfo"];
	    //订单信息
	    $orderinfo=$this->viewdata("id,uid,hid,order_sn,amount,in_time,out_time,info","hotel_order","where order_sn='{$sn}'");
	    if(empty($uinfo)){
	        header("location:?a=login&hid={$orderinfo['hid']}");
	        exit;
	    }
	    if(empty($orderinfo)){die("订单信息错误");}
	    //酒店信息
	    $hotelinfo=$this->viewdata("*","hotel","where id={$orderinfo['hid']}");
	    $userid=$hotelinfo["uid"];
	    //住房信息
	    $info = unserialize($orderinfo["info"]);
	    $tname = $this->oncedata("name","hotel_type","where id={$info[0]['tid']}");
	    $pname = $this->oncedata("name","hotel_type_project","where id={$info[0]['pid']}");
	    //微信信息
	    $wxguest = $this->viewdata("*","wxguest","where userid={$userid} and uid='".$uinfo['uid']."'");
	    
	    //取token
	    $user = $this->viewdata("*","users","where id='{$userid}'");
	    $data['token'] = $user['token'];
	    //统一支付接口
	    $data["userid"]=$userid;
	    $data["sn"]=$sn;
	    $data["title"] = $tname." ".$pname;
	    $data["body"]=$tname;
	    $data["price"]=$orderinfo["amount"];
	    $data["url"]=base64_encode(urlencode($this->basehost."minisite/hotel/?a=notify&orderid={$orderinfo['id']}"));
	    $data["ip"]=getuserip();
	    $data['type'] = empty($_GET['type']) ? 'wap' : $_GET['type'];//'escow'担保交易 'direct'即时到账 wap手机网站支付
	    //if(!empty($wxguest["openid"])){$data["openid"]=$wxguest["openid"];}
	    $paydata=base64_encode(json_encode($data));
	    header("location:{$this->basehost}api/alipay.php?paydata={$paydata}");
	    exit;
	}
	
	
	//用户中心
	public function ucenter(){
		$hid=intval($_GET["hid"]);
		if(empty($hid)){die("酒店信息错误");}
		$uinfo=$_SESSION["uinfo"];
		if(empty($uinfo)){
			header("location:?a=login&hid={$hid}");
			exit;
		}
		$hinfo = $this->viewdata("tel,name,ename","hotel","where id={$hid}");
		$userid=$this->oncedata("uid","hotel","where id={$hid}");
		$this->setwxinfo($userid);
		$wxinfo = $this->viewdata("*","wxuser","where userid={$userid}");
		$jsdata["timestamp"]=time();
		$jsdata["noncestr"] = getrandstr(16);
		$jsdata["url"]=$url='http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
		$jsdata["jsapi_ticket"] = $wxinfo["ticket"];
		$jsdata["signature"] = $this->getjssign($jsdata);
		$jsdata["appid"]=$wxinfo["appid"];
		$this->smarty->assign("hid",$hid);
		$this->smarty->assign("uinfo",$uinfo);
		$this->smarty->assign("jsdata",$jsdata);
		$this->smarty->assign("hinfo",$hinfo);
		$this->smarty->display("ucenter.tpl");
	}
	
	//联系客服
	public function callme(){
		$hid=$_GET["hid"];
		if(empty($hid)){die("酒店信息错误");}
		$hinfo = $this->viewdata("id,tel","hotel","where id={$hid}");
		$this->smarty->assign("hinfo",$hinfo);
		$this->smarty->display("service.tpl");
	}
	
	
	//用户登录
	public function login(){
		if(!empty($_POST)){
			$username = trim($_POST['username']);
			$password = trim($_POST['password']);
			$hid=intval($_POST["hid"]);
			if(!$username || !$password){
				die("<script>top.alert_show('用户名或密码不能为空')</script>");
			}
			$redirectUrl = urlencode($this->basehost."minisite/hotel/?a=getLoginRes&hid={$hid}");
            if($this->basehost=='http://qiyuenew.zhongsou.com/' || $this->basehost=='http://qiyue.zhongsou.com/'){
                $sendurl = 'http://user.zhongsou.com/usercenter/normal/user/signin?username=' . $username . '&password=' . $password . '&redirectUrl=' . $redirectUrl . '&projectId=' . $this->projectId;
            }else{
                $sendurl = 'http://usertest.zhongsou.com/usercenter/normal/user/signin?username=' . $username . '&password=' . $password . '&redirectUrl=' . $redirectUrl . '&projectId=' . $this->projectId;
            }
			header('Location: ' . $sendurl);exit;
		}else{
			$this->smarty->assign("hid",intval($_GET["hid"]));
			$this->smarty->display("hotel_login.tpl");
		}
	}

    /**
     * 获取登录结果
     */
    public function getLoginRes(){
        $code = $_GET['code'];
        if($code=='200'){
            //登录成功
			$this->getUserinfo($_COOKIE['UID']); //设置用户信息至session
           // header('Location:?hid=' . $_GET['hid']);exit;
            die('<script>top.location.href="?a=booking&hid='.$_GET["hid"].'"</script>');
        }else{
            //登录失败
			die("<script>top.alert_show('用户名或密码错误')</script>");
        }
    }
	
	//用户注册
	public function reg(){
		if(!empty($_POST)){
			$username = trim($_POST['username']);
			$password = trim($_POST['password']);
			$hid=intval($_POST["hid"]);
			if(!$username || !$password){
				die("<script>top.alert_show('用户名或密码不能为空')</script>");
			}
			$cres = $this->checkUsername($username);
			$cres = json_decode($cres,true);
			if($cres['code']==200){
                if($this->basehost=='http://qiyuenew.zhongsou.com/' || $this->basehost=='http://qiyue.zhongsou.com/'){
                    $url = 'http://user.zhongsou.com/usercenter/normal/user/signup?username=' . $username . '&password=' . $password . '&projectId=' . $this->projectId;
                }else{
                    $url = 'http://usertest.zhongsou.com:8001/usercenter/normal/user/signup?username=' . $username . '&password=' . $password . '&projectId=' . $this->projectId;
                }
				$rres = file_get_contents($url);
				$rres = json_decode($rres,true);
				if($rres['code']==200){
					$uid = $rres['uid'];
					$this->getUserinfo($uid); //设置用户信息至session
                    die('<script>top.location.href="?a=booking&hid='.$hid.'"</script>');
				}else{
					die("<script>top.alert_show('该手机号已注册')</script>");
				}
			}else{
				die("<script>top.alert_show('该手机号不合法')</script>");
			}
		}else{
			$this->smarty->assign("hid",intval($_GET["hid"]));
			$this->smarty->display("hotel_zhuce.tpl");
		}
	}

    /**
     * 校验用户名是否可用
     */
    public function checkUsername($username=''){
        if($this->basehost=='http://qiyuenew.zhongsou.com/' || $this->basehost=='http://qiyue.zhongsou.com/'){
            $url = 'http://user.zhongsou.com/usercenter/normal/user/username/check?username=' . $username . '&projectId=' . $this->projectId;
        }else{
            $url = 'http://usertest.zhongsou.com:8001/usercenter/normal/user/username/check?username=' . $username . '&projectId=' . $this->projectId;
        }
        return file_get_contents($url);
    }
	
	/**
     * 获取用户信息,设置到session
	 */
	 public function getUserinfo($uid = ''){
            if($this->basehost=='http://qiyuenew.zhongsou.com/' || $this->basehost=='http://qiyue.zhongsou.com/'){
                $sendurl = "http://user.zhongsou.com/usercenter/cors/user/info?UID=".$uid;
            }else{
                $sendurl = "http://usertest.zhongsou.com:8001/usercenter/cors/user/info?UID=".$uid;
            }
			$res = file_get_contents($sendurl);
			$res = json_decode($res,true);
			if($res['code']=='200'){
				$_SESSION['uinfo']['uname']=$res["username"];
				$_SESSION['uinfo']["uid"]=$uid;
				$_SESSION['uinfo']['uface']=$res["avatar"];
				$_SESSION['uinfo']['email']=$res["email"];
				$_SESSION['uinfo']['nickname']=$res["nickname"];
				$_SESSION['uinfo']['mob'] = empty($res['mobile'])?$res["username"]:$res["mobile"];
			}  
	 }

	//提交订单
	public function ordersubmit(){
		$tid=intval($_POST["tid"]);
		$pid=intval($_POST["fid"]);
		$finfo = $this->viewdata("*","hotel_type_project","where id={$pid}");
		if($finfo["pay_type"]==2){
			$status=4;
			$pay_type=2;
		}else{
			$status=1;
			$pay_type=1;
		}
		$hinfo = $this->viewdata("id,uid,tel","hotel","where id={$finfo['hid']}");
		$uinfo = $_SESSION["uinfo"];
		if(empty($uinfo)){
			header("location:?a=login&hid={$finfo['hid']}");
			exit;
		}
		$btim=$_POST["btim"];
		$etim=$_POST["etim"];
		$price=$_POST["allprice"];
		if(empty($price)){
			die("价格信息错误");
		}
		$rnum=intval($_POST["rnum"]);
		$uname=$_POST["uname"];
		$ltim=$_POST["ltim"];
		$mob=$_POST["mob"];
		$sn='Y'.time().rand(1000,9999);
		$ishave = $this->viewdata("id","hotel_order","where hid={$finfo['hid']} and uid='".$uinfo['uid']."' and in_time='{$btim}' and out_time='{$etim}' and amount={$price}");
		if(empty($ishave)){
			$rhaoarr = $this->arrdata("*","hotel_room","where hid={$finfo['hid']} and tid={$tid} and rtype=1 and status=1","id desc","limit {$rnum}");
			if(!empty($rhaoarr)){
				foreach($rhaoarr as $k=>$v){
					$rhao.=$rhaoarr[$k]["name"].",";
					$this->updata("hotel_room","rtype=3","where id={$rhaoarr[$k]['id']}");
				}
			}
			$rhao = trim($rhao,",");
			$info=serialize(array(0=>array("tid"=>$tid,"pid"=>$pid,"prices"=>$price,"rhao"=>$rhao,"rnum"=>$rnum)));
			$into="order_sn='{$sn}',uid='".$uinfo['uid']."',create_name='{$uname}',create_phone='{$mob}',vip_num='',in_time='{$btim}',out_time='{$etim}',liu_time='{$ltim}',pay_type={$pay_type},type=1";
			$into.=",remark='',team_info='',status={$status},up_time=now(),add_time=now(),amount={$price},info='{$info}',hid={$finfo['hid']},cash=0,payment=0,mold=1,source=1";
			$newid = $this->setdata("hotel_order",$into);
		}else{
			$newid = $ishave["id"];
		}
		if(!empty($newid)){
			$this->smarty->assign("sn",$sn);
			$this->smarty->assign("wxpay",$status);
			$this->smarty->assign("status",$status);
			$this->smarty->assign("hid",$finfo['hid']);
			$this->smarty->assign("hinfo",$hinfo);
			$this->smarty->display("hotel_order_submit.tpl");
		}else{
			die("订单生成失败");
		}
	}
	
	//订单详情
	public function myorder(){
		$id=intval($_GET["orderid"]);
		$hid=intval($_GET["hid"]);
		if(empty($hid)){die("酒店信息错误");}
		$uinfo=$_SESSION["uinfo"];
		if(empty($uinfo)){
			header("location:?a=login&hid={$hid}");
			exit;
		}
		$order = $this->viewdata("*","hotel_order","where id={$id}");
		if(!empty($order)){
			if(!empty($order["info"])){
				$tinfo = unserialize($order["info"]);
				foreach($tinfo as $k=>$v){
					if(!empty($tinfo[$k]['tid'])){
					$tinfo[$k]["tname"]=$this->oncedata("name","hotel_type","where id={$tinfo[$k]['tid']}");
					}
					if(!empty($tinfo[$k]['pid'])){
					$tinfo[$k]["pname"] = $this->oncedata("name","hotel_type_project","where id={$tinfo[$k]['pid']}");
					}
				}
				$order["tinfo"] = $tinfo;
			}
			$order["daynum"] = intval((strtotime($order["out_time"]) - strtotime($order["in_time"]))/86400);
		}
		$hinfo=$this->viewdata("*","hotel","where id={$hid}");
		$this->smarty->assign("order",$order);
		$this->smarty->assign("hinfo",$hinfo);
		$this->smarty->display("detail.tpl");
	}
	//我的订单
	public function myorderlist(){
		$hid=$_GET["hid"];
		if(empty($hid)){die("酒店信息错误");}
		$uinfo=$_SESSION["uinfo"];
		if(empty($uinfo)){
			header("location:?a=login&hid={$hid}");
			exit;
		}
		$statusarr=array(1=>"已预订",2=>"已入住",3=>"已取消",4=>"未付款",5=>"已付款",6=>"部分入住",7=>"已完成");
		$order = $this->arrdata("*","hotel_order","where uid='{$uinfo['uid']}' and hid={$hid} ","id desc");
		if(!empty($order)){
			foreach($order as $k=>$v){
				if(!empty($order[$k]["info"])){
					$tinfo = unserialize($order[$k]["info"]);
					foreach($tinfo as $kk=>$vv){
						if(!empty($tinfo[$kk]['tid'])){
							$tinfo[$kk]["tname"]=$this->oncedata("name","hotel_type","where id={$tinfo[$kk]['tid']}");
						}
						if(!empty($tinfo[$kk]['pid'])){
							$tinfo[$kk]["pname"] = $this->oncedata("name","hotel_type_project","where id={$tinfo[$kk]['pid']}");
						}
					}
					$order[$k]["tinfo"] = $tinfo;
				}
				$order[$k]["statusname"]=$statusarr[$order[$k]["status"]];
			}
		}
		$hinfo=$this->viewdata("id,name,uid","hotel","where id={$hid}");
		$this->smarty->assign("list",$order);
		$this->smarty->assign("hinfo",$hinfo);
		$this->smarty->display("order.tpl");
	}
	
	//删除订单
	public function delmyorder(){
		$id=intval($_GET["orderid"]);
		if(empty($id)){die("订单ID错误");}
		$view=$this->viewdata("id,uid,hid,info","hotel_order","where id={$id}");
		if(empty($view)){die("订单不存在");}
		$uinfo = $_SESSION["uinfo"];
		if(empty($uinfo)){
			header("location:?a=login&hid={$view['hid']}");
			exit;
		}
		if($uinfo['uid'] != $view["uid"]){
			die($uinfo['uid'].'!='.$view["uid"]);
		}
		$this->updata("hotel_order","status=3","where id={$id}");
		$info = unserialize($view["info"]);
		if(!empty($info[0]["rhao"])){
			$rarr = explode(",",$info[0]["rhao"]);
			foreach($rarr as $v){
				$this->updata("hotel_room","rtype=1","where name='{$v}'");
			}
		}
		header("location:?a=myorderlist&hid={$view['hid']}");
		exit;
	}
	
	//订单支付异步请求
	public function notify(){
		$id=intval($_GET["orderid"]);
		$orderinfo = $this->viewdata("*","hotel_order","where id={$id}");
		if(!empty($orderinfo)){
			$this->setdata("hotel_pay_log","orderid={$id},tim=now()");
			$this->updata("hotel_order","status=5","where id={$id}");
			header("location:?a=myorderlist&hid={$orderinfo['hid']}");
			exit;
		}else{
			die("订单信息错误");
			exit;
		}
	}
	
	//酒店地图
	public function map(){
		$hid=intval($_GET["hid"]);
		if(empty($hid)){die("酒店信息错误");}
		$hinfo = $this->viewdata("id,latitude,longitude,name,ename","hotel","where id={$hid}");
		$this->smarty->assign("hinfo",$hinfo);
		$this->smarty->display("map.tpl");
	}
	
	//房型信息
	public function roominfo(){
		$tid=intval($_GET["tid"]);
		if(empty($tid)){die("房型信息错误");}
		$tinfo = $this->viewdata("*","hotel_type","where id={$tid}");
		$tinfo["fname"]=$this->oncedata("name","hotel_floor","where id={$tinfo['fid']}");
		$this->smarty->assign("tinfo",$tinfo);
		$this->smarty->display("hotel_room.tpl");
	}
	
	public function logout(){
		unset($_COOK);
		unset($_SESSION);
		$hid=intval($_GET["hid"]);
		header("location:?a=login&hid={$hid}");
		exit;
	}
	
	
	//个人资料
	public function myinfo(){
		$uinfo=$_SESSION["uinfo"];
		if(empty($uinfo)){
			header("location:?a=login");
			exit;
		}
		$this->smarty->assign("uinfo",$uinfo);
		$this->smarty->display("pinfo.tpl");
	}
	

}